document.ready(function() {
    queryKey('ok');
});

function queryKey(flag) {
    openLoad();
    resetPageBar(flag);

    var param = {};
    param.ctrl = 'record';
    param.func = 'getReportList';
    param.reasonInfo = getAjaxValue('reasonInfo');
    param.statusInfo = getAjaxValue('statusInfo');
    param.startdate = getAjaxValue('startdate');
    param.enddate = getAjaxValue('enddate');
    param.page = getAjaxValue('page');

    sendAjax(param, function(result) {
        report.list = result.report;
        
        loadPageBar(getValue('page'), result.allPages, result.rowCount);
        setHtml('listCount', result.listCount);

        setDisplay('mainBg', '');
        closeLoad();
    });
}

function handleReport(reportid) {
    setValue('tempid', reportid);
    layer.prompt({title: '请填写处理结果', offset: ['100px', tipleft], formType: 0}, function(value, index) {
        var param = {};
        param.ctrl = 'record';
        param.func = 'handleReport';
        param.reportid = getAjaxValue('tempid');
        param.result = encodeURIComponent(value);

        sendAjax(param, function(result) {
            submitRecord('edit', '举报信息列表页', '处理举报', getValue('tempid'));
            parent.setWaitWorkCount('subMenuNum_record_report', result.waitReportCount);
            parent.setMainMenuDot();
            queryKey('page');
        });

        layer.close(index);
    });
}

function clickOperateItem(reportid, association, module0, event) {
    var flag = event.currentTarget.options[event.currentTarget.selectedIndex].value;
    if (flag == 'view') {
        if (module0 == 'electronic') {
            openSlipIframeDiv('admin.php?m=electronic&c=info&electronicid=' + association);
        }
        else if (module0 == 'housecraft') {
            openSlipIframeDiv('admin.php?m=housecraft&c=info&housecraftid=' + association);
        }
        else if (module0 == 'other') {
            openSlipIframeDiv('admin.php?m=other&c=info&otherid=' + association);
        }
    }
    else if (flag == 'log') {
        openSlipIframeDiv('admin.php?m=record&c=log&association=' + reportid + '&title=' + escape('举报处理'));
    }
    else {
        showTip('菜单类型异常');
    }
    
    event.currentTarget.options[0].selected = true;
}